<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="PersonaListForm">

        <p:panel header="#{bundle.ListPersonaTitle}">

            <p:dataTable id="datalist" value="#{personaController.items}" var="item"
                         selectionMode="single" selection="#{personaController.selected}"
                         rowKey="#{item.id}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30"
                         >

                <p:ajax event="rowSelect"   update="createButton viewButton editButton deleteButton"/>
                <p:ajax event="rowUnselect" update="createButton viewButton editButton deleteButton"/>

                <p:column sortBy="#{item.id}" filterBy="#{item.id}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_id}"/>
                    </f:facet>
                    <h:outputText value="#{item.id}"/>
                </p:column>
                <p:column sortBy="#{item.nombre1}" filterBy="#{item.nombre1}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_nombre1}"/>
                    </f:facet>
                    <h:outputText value="#{item.nombre1}"/>
                </p:column>
                <p:column sortBy="#{item.nombre2}" filterBy="#{item.nombre2}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_nombre2}"/>
                    </f:facet>
                    <h:outputText value="#{item.nombre2}"/>
                </p:column>
                <p:column sortBy="#{item.apellido1}" filterBy="#{item.apellido1}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_apellido1}"/>
                    </f:facet>
                    <h:outputText value="#{item.apellido1}"/>
                </p:column>
                <p:column sortBy="#{item.apellido2}" filterBy="#{item.apellido2}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_apellido2}"/>
                    </f:facet>
                    <h:outputText value="#{item.apellido2}"/>
                </p:column>
                <p:column sortBy="#{item.fechaNacimiento}" filterBy="#{item.fechaNacimiento}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_fechaNacimiento}"/>
                    </f:facet>
                    <h:outputText value="#{item.fechaNacimiento}">
                        <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                </p:column>
                <p:column sortBy="#{item.direccion1}" filterBy="#{item.direccion1}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_direccion1}"/>
                    </f:facet>
                    <h:outputText value="#{item.direccion1}"/>
                </p:column>
                <p:column sortBy="#{item.direccion2}" filterBy="#{item.direccion2}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_direccion2}"/>
                    </f:facet>
                    <h:outputText value="#{item.direccion2}"/>
                </p:column>
                <p:column sortBy="#{item.telefono}" filterBy="#{item.telefono}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_telefono}"/>
                    </f:facet>
                    <h:outputText value="#{item.telefono}"/>
                </p:column>
                <p:column sortBy="#{item.celular}" filterBy="#{item.celular}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_celular}"/>
                    </f:facet>
                    <h:outputText value="#{item.celular}"/>
                </p:column>
                <p:column sortBy="#{item.creationDate}" filterBy="#{item.creationDate}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_creationDate}"/>
                    </f:facet>
                    <h:outputText value="#{item.creationDate}">
                        <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:outputText>
                </p:column>
                <p:column sortBy="#{item.createdBy}" filterBy="#{item.createdBy}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_createdBy}"/>
                    </f:facet>
                    <h:outputText value="#{item.createdBy}"/>
                </p:column>
                <p:column sortBy="#{item.lastUpdateDate}" filterBy="#{item.lastUpdateDate}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_lastUpdateDate}"/>
                    </f:facet>
                    <h:outputText value="#{item.lastUpdateDate}">
                        <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:outputText>
                </p:column>
                <p:column sortBy="#{item.lastUpdateBy}" filterBy="#{item.lastUpdateBy}">
                    <f:facet name="header">
                        <h:outputText value="#{bundle.ListPersonaTitle_lastUpdateBy}"/>
                    </f:facet>
                    <h:outputText value="#{item.lastUpdateBy}"/>
                </p:column>
                <f:facet name="footer">
                    <p:commandButton id="createButton" icon="ui-icon-plus"   value="#{bundle.Create}" actionListener="#{personaController.prepareCreate}" update=":PersonaCreateForm" oncomplete="PersonaCreateDialog.show()"/>
                    <p:commandButton id="viewButton"   icon="ui-icon-search" value="#{bundle.View}" update=":PersonaViewForm" oncomplete="PersonaViewDialog.show()" disabled="#{empty personaController.selected}"/>
                    <p:commandButton id="editButton"   icon="ui-icon-pencil" value="#{bundle.Edit}" update=":PersonaEditForm" oncomplete="PersonaEditDialog.show()" disabled="#{empty personaController.selected}"/>
                    <p:commandButton id="deleteButton" icon="ui-icon-trash"  value="#{bundle.Delete}" actionListener="#{personaController.delete}" update=":growl,datalist" disabled="#{empty personaController.selected}"/>
                </f:facet>

            </p:dataTable>

        </p:panel>

    </h:form>

</ui:composition>